import type { CsRadioGroupProps } from 'csui'

type UseCsRadioGroupProps<
  D extends Record<string, any>,
  P extends keyof Readonly<D>
> = UseFormItemProps<CsRadioGroupProps, D, P>

/**
 * 单选框组
 * @param prop item.prop
 * @param label item.label
 * @param props item的其他属性
 * @returns form-item-data
 */
export function useRadioGroup<
  T extends Record<string, any>,
  P extends keyof T
>(
  prop: P,
  label: string,
  props: UseCsRadioGroupProps<T, P> = {}
): FormItemProps<T, P> {
  return {
    prop,
    label,
    ...props,
    component: 'cs-radio-group'
  }
}
